package capimServer;

import java.util.TimerTask;

/**
 * Resend packets, if timer is done
 * @author danielm pessoafpc
 *
 */
public class ReSendPkt extends TimerTask {
	int pktId;
	PacketQueue queue;

	public ReSendPkt(PacketQueue queue) {
		this.setPktId(pktId);
		this.setQueue(queue);
	}
	

	@Override
	public void run() {
		for(int i=0; i < this.getQueue().size; i++){
			try {
				if(!this.getQueue().isEmpty())CapimServer.postOffice.reSendMessage(this.getQueue().remove());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
	}
	
	public int getPktId() {
		return pktId;
	}

	public void setPktId(int pktId) {
		this.pktId = pktId;
	}
	
	public PacketQueue getQueue() {
		return queue;
	}

	public void setQueue(PacketQueue queue) {
		this.queue = queue;
	}

}
